package factory;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

// one option under to be selected

/**
 * @author Steve
 * ItemMenu class.  One item under this menu must be selected
 */
public class ItemMenu extends LoadableMenu{

	/**
	 * @param args
	 * @param input
	 */
	public ItemMenu(LinkedList<String> args, Scanner input){ 
		super(args, input); 
	}

	/** 
	 * returns OrderObject item
	 * @return OrderObject or item in list
	 */
	@Override
	public OrderObject getOrder(Scanner in){
		if(options.size() == 0)
			return new OrderObject(name, price, display);


		ArrayList<String> choices = new ArrayList<String>();
		for(LoadableMenu lm : options)
			choices.add(lm.name);


		System.out.println("\nSelecting a " + name);
		System.out.println("\nPlease select the next option.");

		int selection = presentMenu(choices, in);
		OrderObject item = options.get(selection).getOrder(in); // getSelection

		return new OrderObject(name, price, display, item);
	}
}
